/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Aux_Lista.java
 *
 * Created on 04-abr-2013, 22:17:09
 */
package jumavidesktop.GUI.Principal;

import java.awt.Image;
import java.text.DateFormat;
import java.util.Locale;
import javax.swing.ImageIcon;
import jumavidesktop.Persistencia.entidades.EnumeracionesEntidades.TipoMovimiento;
import jumavidesktop.Persistencia.entidades.Movimientos;

/**
 *
 * @author kjh
 */
public class Aux_Lista extends javax.swing.JPanel {
    static int numlista=-1;
    private Movimientos m;
    
    public enum Mensaje{ENTRADA,SALIDA}
    /** Creates new form Aux_Lista */
    public Aux_Lista() {
        super();
        initComponents();
        this.setVisible(true);
        numlista++;
    }
    
    public Aux_Lista(Movimientos m){
        this();
        this.m=m;
        setMovimientos();
    }
    
    public void setMovimientos(){
        setCam(m.getCamaraid().getId().toString());
        setMat(m.getMatricula().getMatricula());
        setHora(DateFormat.getInstance().format(m.getFechaYHora()));
        setId(Integer.toString(numlista));
        setSemaforo(m.getMovimiento());     
    }
    
    public void setCam(String valor){
        this.label_Cam.setText(valor);
    }
    
    public void setMat(String valor){
        this.label_Matr.setText(valor);
    }
    
    public void setHora(String valor){
        this.label_Hora.setText(valor);
    }
    
    public void setId(String valor){
        this.label_Id.setText(valor);
    }
    
    public void setSal(String valor){
        this.label_Sal.setText(valor);
    }
    
    private void setSemaforo(TipoMovimiento valor){
        switch(valor){
            case ENTRADA:
                this.accesoPermitido();
                break;
            
            case SALIDA:
                this.accesoDenegado();
                break;
        }
    }
    
    private void accesoPermitido(){
        ImageIcon tmpIconAux = new ImageIcon(getClass().getResource("/jumavidesktop/recursos/iconos/cuad_verdesin.png"));
        ImageIcon tmpIcon = new ImageIcon(tmpIconAux.getImage().getScaledInstance(38, -1, Image.SCALE_DEFAULT));
        this.label_Sal.setIcon(tmpIcon);    
    }
    
    private void accesoDenegado(){
        ImageIcon tmpIconAux = new ImageIcon(getClass().getResource("/jumavidesktop/recursos/iconos/cuad_rojosin.png"));
        ImageIcon tmpIcon = new ImageIcon(tmpIconAux.getImage().getScaledInstance(38, -1, Image.SCALE_DEFAULT));
        this.label_Sal.setIcon(tmpIcon);
    } 
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel_Sal = new javax.swing.JPanel();
        label_Sal = new javax.swing.JLabel();
        panel_Derecho = new javax.swing.JPanel();
        panel_Cam = new javax.swing.JPanel();
        label_Cam = new javax.swing.JLabel();
        panel_Hora = new javax.swing.JPanel();
        label_Hora = new javax.swing.JLabel();
        panel_Matr = new javax.swing.JPanel();
        label_Matr = new javax.swing.JLabel();
        panel_Id = new javax.swing.JPanel();
        label_Id = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        setMaximumSize(new java.awt.Dimension(32767, 45));
        setMinimumSize(new java.awt.Dimension(0, 45));

        panel_Sal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panel_Sal.setMaximumSize(new java.awt.Dimension(45, 45));
        panel_Sal.setOpaque(false);

        label_Sal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_Sal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout panel_SalLayout = new javax.swing.GroupLayout(panel_Sal);
        panel_Sal.setLayout(panel_SalLayout);
        panel_SalLayout.setHorizontalGroup(
            panel_SalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 56, Short.MAX_VALUE)
            .addGroup(panel_SalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(label_Sal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE))
        );
        panel_SalLayout.setVerticalGroup(
            panel_SalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
            .addGroup(panel_SalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(label_Sal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE))
        );

        panel_Derecho.setLayout(new javax.swing.BoxLayout(panel_Derecho, javax.swing.BoxLayout.X_AXIS));

        panel_Cam.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panel_Cam.setMaximumSize(new java.awt.Dimension(308, 32767));
        panel_Cam.setMinimumSize(new java.awt.Dimension(308, 0));

        label_Cam.setText("Cámara");

        javax.swing.GroupLayout panel_CamLayout = new javax.swing.GroupLayout(panel_Cam);
        panel_Cam.setLayout(panel_CamLayout);
        panel_CamLayout.setHorizontalGroup(
            panel_CamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 304, Short.MAX_VALUE)
            .addGroup(panel_CamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_CamLayout.createSequentialGroup()
                    .addGap(0, 133, Short.MAX_VALUE)
                    .addComponent(label_Cam)
                    .addGap(0, 134, Short.MAX_VALUE)))
        );
        panel_CamLayout.setVerticalGroup(
            panel_CamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
            .addGroup(panel_CamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_CamLayout.createSequentialGroup()
                    .addGap(0, 12, Short.MAX_VALUE)
                    .addComponent(label_Cam)
                    .addGap(0, 13, Short.MAX_VALUE)))
        );

        panel_Derecho.add(panel_Cam);

        panel_Hora.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panel_Hora.setMaximumSize(new java.awt.Dimension(308, 32767));
        panel_Hora.setMinimumSize(new java.awt.Dimension(308, 0));

        label_Hora.setText("Hora");

        javax.swing.GroupLayout panel_HoraLayout = new javax.swing.GroupLayout(panel_Hora);
        panel_Hora.setLayout(panel_HoraLayout);
        panel_HoraLayout.setHorizontalGroup(
            panel_HoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 304, Short.MAX_VALUE)
            .addGroup(panel_HoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_HoraLayout.createSequentialGroup()
                    .addGap(0, 141, Short.MAX_VALUE)
                    .addComponent(label_Hora)
                    .addGap(0, 140, Short.MAX_VALUE)))
        );
        panel_HoraLayout.setVerticalGroup(
            panel_HoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
            .addGroup(panel_HoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_HoraLayout.createSequentialGroup()
                    .addGap(0, 12, Short.MAX_VALUE)
                    .addComponent(label_Hora)
                    .addGap(0, 13, Short.MAX_VALUE)))
        );

        panel_Derecho.add(panel_Hora);

        panel_Matr.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panel_Matr.setMaximumSize(new java.awt.Dimension(308, 32767));
        panel_Matr.setMinimumSize(new java.awt.Dimension(308, 0));

        label_Matr.setText("Matrícula");

        javax.swing.GroupLayout panel_MatrLayout = new javax.swing.GroupLayout(panel_Matr);
        panel_Matr.setLayout(panel_MatrLayout);
        panel_MatrLayout.setHorizontalGroup(
            panel_MatrLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 304, Short.MAX_VALUE)
            .addGroup(panel_MatrLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_MatrLayout.createSequentialGroup()
                    .addGap(0, 131, Short.MAX_VALUE)
                    .addComponent(label_Matr)
                    .addGap(0, 130, Short.MAX_VALUE)))
        );
        panel_MatrLayout.setVerticalGroup(
            panel_MatrLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
            .addGroup(panel_MatrLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_MatrLayout.createSequentialGroup()
                    .addGap(0, 12, Short.MAX_VALUE)
                    .addComponent(label_Matr)
                    .addGap(0, 13, Short.MAX_VALUE)))
        );

        panel_Derecho.add(panel_Matr);

        panel_Id.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        panel_Id.setMaximumSize(new java.awt.Dimension(308, 32767));
        panel_Id.setMinimumSize(new java.awt.Dimension(308, 0));
        panel_Id.setPreferredSize(new java.awt.Dimension(308, 38));

        label_Id.setText("Nº Operación");

        javax.swing.GroupLayout panel_IdLayout = new javax.swing.GroupLayout(panel_Id);
        panel_Id.setLayout(panel_IdLayout);
        panel_IdLayout.setHorizontalGroup(
            panel_IdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 304, Short.MAX_VALUE)
            .addGroup(panel_IdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_IdLayout.createSequentialGroup()
                    .addGap(0, 120, Short.MAX_VALUE)
                    .addComponent(label_Id)
                    .addGap(0, 120, Short.MAX_VALUE)))
        );
        panel_IdLayout.setVerticalGroup(
            panel_IdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
            .addGroup(panel_IdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_IdLayout.createSequentialGroup()
                    .addGap(0, 12, Short.MAX_VALUE)
                    .addComponent(label_Id)
                    .addGap(0, 13, Short.MAX_VALUE)))
        );

        panel_Derecho.add(panel_Id);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panel_Sal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panel_Derecho, javax.swing.GroupLayout.DEFAULT_SIZE, 1232, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel_Derecho, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
            .addComponent(panel_Sal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel label_Cam;
    private javax.swing.JLabel label_Hora;
    private javax.swing.JLabel label_Id;
    private javax.swing.JLabel label_Matr;
    private javax.swing.JLabel label_Sal;
    private javax.swing.JPanel panel_Cam;
    private javax.swing.JPanel panel_Derecho;
    private javax.swing.JPanel panel_Hora;
    private javax.swing.JPanel panel_Id;
    private javax.swing.JPanel panel_Matr;
    private javax.swing.JPanel panel_Sal;
    // End of variables declaration//GEN-END:variables
}
